"colorscheme slate
set t_Co=256          "解决tmux和vim颜色冲突问题
set nofoldenable      "启动是关闭折叠,za打开或关闭当前折叠，zM关闭所有折叠，zR打开所有折叠
set foldmethod=syntax "基于语法进行折叠
set foldmethod=indent "基于缩进进行折叠
set hlsearch
syntax on "语法高亮
syntax enable        "允许其他配色方案替代默认配色
filetype indent on   "适应文件类型的自动缩进
filetype plugin on
filetype on          "文件类型检测开启
set number           "显示行号

nnoremap <c-h> <Esc>ddkP
nnoremap <c-l> <Esc>ddp
nnoremap <tab> gt
inoremap HH <Esc>i
inoremap LL <Esc>la
nnoremap H <Esc>^
nnoremap L <Esc>g_
inoremap jk <Esc>
"inoremap <esc> <nop>
"inoremap ' ''<Esc>i
"inoremap " ""<Esc>i
"inoremap ( ()<Esc>i
"inoremap [ []<Esc>i
"inoremap { {<CR>}<Esc>ko

set ts=4             "设置制表符占用空格数
set shiftwidth=4     "设置格式化时制表符占用空格数
set autoindent       "自动缩进
set cindent          "针对c的自动缩进

"if exists('$TMUX')
"    set term=sreen-256color
"endif
map <F5> :call Compile()<CR>
func! Compile()
	exec "w"
	if &filetype == "c"
		exec "!gcc % -o %<"
		exec "!./%<"
	elseif &filetype == "cpp"
		exec "!g++ % -o %<"
		exec "!./%<"
	elseif &filetype == "python"
		exec "!python %"
	endif
endfunc

map <F8> :call Debug()<CR>
func! Debug()
	exec "w"
	if &filetype == "c"
		exec "!gcc % -g -o %<"
		exec "!gdb %<"
	elseif &filetype == "cpp"
		exec "!g++ % -g -o %<"
		exec "!gdb %<"
	endif
endfunc

call plug#begin('~/.vim/plugged')

Plug 'scrooloose/nerdtree'
Plug 'vim-airline/vim-airline'
"Plug 'scrooloose/nerdcommenter'

call plug#end()



""""""""""""""""""""""""""""""NERDTree 配置"""""""""""""""""""""""""""""""""
" 自动启动插件
"autocmd vimenter * NERDTree 
" 退出主窗口时退出NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
map <C-n> :NERDTreeToggle<CR>



""""""""""""""""""""""""""""""airline 配置""""""""""""""""""""""""""""""""""
if !exists('g:airline_symbols')
    let g:airline_symbols = {}
endif
let g:airline#extensions#tabline#enabled = 1 "配置tabline
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '>'
let g:airline#extensions#tabline#formatter = 'unique_tail'

let g:airline_section_b = '%{strftime("%c")}'
let g:airline_section_y = 'BN: %{bufnr("%")}'
let g:airline_powerline_fonts = 1
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
